class Jspreadsheet extends HTMLElement {
  constructor() {
    super();
  }

  init(o) {
    // Shadow root
    const shadowRoot = this.attachShadow({
      mode: 'open'
    });

    // Style
    const css = document.createElement('link');
    css.rel = 'stylesheet';
    css.type = 'text/css'
    // css.href = 'https://bossanova.uk/jexcel/v4/jexcel.css';
    css.href = '../css/jexcel.css';
    shadowRoot.appendChild(css);

    const css2 = document.createElement('link');
    css2.rel = 'stylesheet';
    css2.type = 'text/css'
    // css2.href = 'https://bossanova.uk/jexcel/v4/jsuites.css';
    css2.href = '../css/jsuites.css';
    shadowRoot.appendChild(css2);

    // Jspreadsheet container
    var container = document.createElement('div');
    shadowRoot.appendChild(container);

    // Create element
    this.el = jspreadsheet(container, {
      root: shadowRoot,
      minDimensions: [10, 10],
      text: {
        "noRecordsFound": "未找到",
        "showingPage": "显示 {1} 条中的第 {0} 条",
        "show": "显示 ",
        "search": "搜索",
        "entries": " 条目",
        "columnName": "列标题",
        "insertANewColumnBefore": "在此前插入列",
        "insertANewColumnAfter": "在此后插入列",
        "deleteSelectedColumns": "删除选定列",
        "renameThisColumn": "重命名列",
        "orderAscending": "升序",
        "orderDescending": "降序",
        "insertANewRowBefore": "在此前插入行",
        "insertANewRowAfter": "在此后插入行",
        "deleteSelectedRows": "删除选定行",
        "editComments": "编辑批注",
        "addComments": "插入批注",
        "comments": "批注",
        "clearComments": "删除批注",
        "copy": "复制...",
        "paste": "粘贴...",
        "saveAs": "保存为...",
        "about": "关于",
        "areYouSureToDeleteTheSelectedRows": "确定删除选定行?",
        "areYouSureToDeleteTheSelectedColumns": "确定删除选定列?",
        "thisActionWillDestroyAnyExistingMergedCellsAreYouSure": "这一操作会破坏所有现存的合并单元格，确认操作？",
        "thisActionWillClearYourSearchResultsAreYouSure": "这一操作会清空搜索结果，确认操作？",
        "thereIsAConflictWithAnotherMergedCell": "与其他合并单元格有冲突",
        "invalidMergeProperties": "无效的合并属性",
        "cellAlreadyMerged": "单元格已合并",
        "noCellsSelected": "未选定单元格"
      }
    });
  }

  connectedCallback() {
    this.init(this);
  }

  disconnectedCallback() {}

  attributeChangedCallback() {}
}

window.customElements.define('j-spreadsheet', Jspreadsheet);